package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.danmo.domain.DanmoArtSchool;
import com.muyu.danmo.service.IDanmoArtSchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 办学类型Controller
 *
 * @author yangle
 * @date 2024-10-31
 */
@RestController
@RequestMapping("/artSchool")
public class DanmoArtSchoolController extends BaseController
{
    @Autowired
    private IDanmoArtSchoolService danmoArtSchoolService;

    /**
     * 查询办学类型列表
     */
//    @RequiresPermissions("system:artSchool:list")
    @PostMapping("/list")
    public Result<List<DanmoArtSchool>> list(@RequestBody DanmoArtSchool danmoArtSchool)
    {
        List<DanmoArtSchool> list = danmoArtSchoolService.selectDanmoArtSchoolList(danmoArtSchool);
        return Result.success(list);
    }

    /**
     * 导出办学类型列表
     */
    @RequiresPermissions("system:artSchool:export")
    @Log(title = "办学类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoArtSchool danmoArtSchool)
    {
        List<DanmoArtSchool> list = danmoArtSchoolService.selectDanmoArtSchoolList(danmoArtSchool);
        ExcelUtil<DanmoArtSchool> util = new ExcelUtil<DanmoArtSchool>(DanmoArtSchool.class);
        util.exportExcel(response, list, "办学类型数据");
    }

    /**
     * 获取办学类型详细信息
     */
    @RequiresPermissions("system:artSchool:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoArtSchoolService.selectDanmoArtSchoolById(id));
    }

    /**
     * 新增办学类型
     */
    @RequiresPermissions("system:artSchool:add")
    @Log(title = "办学类型", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoArtSchool danmoArtSchool)
    {
        return toAjax(danmoArtSchoolService.insertDanmoArtSchool(danmoArtSchool));
    }

    /**
     * 修改办学类型
     */
    @RequiresPermissions("system:artSchool:edit")
    @Log(title = "办学类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoArtSchool danmoArtSchool)
    {
        return toAjax(danmoArtSchoolService.updateDanmoArtSchool(danmoArtSchool));
    }

    /**
     * 删除办学类型
     */
    @RequiresPermissions("system:artSchool:remove")
    @Log(title = "办学类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoArtSchoolService.deleteDanmoArtSchoolByIds(ids));
    }
}
